using System.Globalization;

namespace Flit
{
    ///<summary>
    /// Represents a data type and a name
    ///</summary>
    public class Parameter
    {
        internal Parameter(string type, string name)
        {
            DataType = type;
            Name = name;
        }

        ///<summary>
        /// The data type of this parameter
        ///</summary>
        public string DataType { get; set; }

        /// <summary>
        /// The name of this parameter
        /// </summary>
        public string Name { get; set; }

        ///<summary>
        /// Formats this parameter as a property declaration <example>int Foo{get;set;}</example>
        ///</summary>
        public string AsPropertyDeclaration
        {
            get { return "{0} {1} {{get;set;}}".InvariantFormat(DataType, TitleCaseName); }
        }
        
        ///<summary>
        /// Formats this parameter as an internal property setter <example>this.foo=foo</example>
        ///</summary>
        public string AsPropertySetter
        {
            get { return "this.{0} = {1}".InvariantFormat(TitleCaseName, LowercaseName); }
        }

        /// <summary>
        /// Formats this parameter as a parameter declaration, such as a method declaration item <example>int fooF</example>
        /// </summary>
        public string AsParameterDeclaration
        {
            get { return "{0} {1}".InvariantFormat(DataType, LowercaseName); }
        }

        /// <summary>
        /// Convert the name of this parameter to Titlecase
        /// </summary>
        internal string TitleCaseName
        {
            get
            {
                char[] array = Name.ToCharArray();
                array[0] = char.ToUpper(array[0], CultureInfo.InvariantCulture);
                return new string(array);
            }
        }

        /// <summary>
        /// Convert the name of this parameter to lowercase
        /// </summary>
        internal string LowercaseName
        {
            get
            {
                char[] array = Name.ToCharArray();
                array[0] = char.ToLower(array[0], CultureInfo.InvariantCulture);
                return new string(array);
            }
        }
    }
}